//
// Created by LiuYou on 2021/7/23.
//

#ifndef MODERNCPP_HASPTRLIKEPTRUSESMARTPOINTER_HPP
#define MODERNCPP_HASPTRLIKEPTRUSESMARTPOINTER_HPP


#include <memory>
#include <ostream>

namespace ResourceManagement {
    class HasPtrLikePtrUseSmartPointer {
    public:
        /// \brief 注意: ! 这个就没有必要了, 使用指针指针管理的类没有必要自己写一份copy assignment operator。
        /// \param lhs
        /// \param rhs
        friend void swap(HasPtrLikePtrUseSmartPointer& lhs, HasPtrLikePtrUseSmartPointer& rhs) {
        }

    public:
        friend std::ostream& operator<<(std::ostream& os, const HasPtrLikePtrUseSmartPointer& pointer) {
            os << "{" << "sharedPtrString: " << pointer.sharedPtrString
               << ", *sharedPtrString: " << "\"" << *pointer.sharedPtrString << "\""
               << ", defaultValue: " << pointer.defaultValue << "}";
            return os;
        }

    public:
        explicit HasPtrLikePtrUseSmartPointer(const std::string& string = std::string());

        virtual ~HasPtrLikePtrUseSmartPointer();

        HasPtrLikePtrUseSmartPointer(const HasPtrLikePtrUseSmartPointer& rhs) = default;

        HasPtrLikePtrUseSmartPointer& operator=(const HasPtrLikePtrUseSmartPointer& rhs) = default;

    private:
        std::shared_ptr<std::string> sharedPtrString;
        int defaultValue;

    };

}


#endif //MODERNCPP_HASPTRLIKEPTRUSESMARTPOINTER_HPP
